const { defineConfig } = require('@vue/cli-service')
const path = require('path');
const packageName = require('./package').name;

function resolve(dir) {
  return path.join(__dirname, dir);
}

const port = 7301; // dev port
module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: `/${packageName}`,
  outputDir: 'dist',
  assetsDir: 'static',
  devServer: {
    host: '0.0.0.0',
    hot: true,
    port: port,
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
  },
  // 自定义webpack配置
  configureWebpack: {
      resolve: {
        alias: {
          '@': resolve('src'),
        },
      },
      output: {
        // 把子应用打包成 umd 库格式
        library: `${packageName}-[name]`,
        libraryTarget: 'umd',
        // webpack v5用chunkLoadingGlobal字段；webpack v4用jsonpFunction字段
        chunkLoadingGlobal: `webpackJsonp_${packageName}`, 
      },
  },
})
